package com.kupurui.asteacher.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.kupurui.asteacher.R;
import com.kupurui.asteacher.bean.PreReleaseInfo;
import com.kupurui.asteacher.bean.PushClassInfo;

import java.util.List;

/**
 * Created by Administrator on 2017/7/25.
 */

public class PreRelesaeClassAdapter extends CommonAdapter<PreReleaseInfo.SchoolBean> {
    public PreRelesaeClassAdapter(Context context, List<PreReleaseInfo.SchoolBean> mList, int itemLayoutId) {
        super(context, mList, itemLayoutId);
    }

    @Override
    public void convert(ViewHolder holder, final PreReleaseInfo.SchoolBean item, int positon) {
        holder.setTextViewText(R.id.tv_school_name,"学校："+item.getSchool());
        holder.setTextViewText(R.id.tv_grade,"年级："+item.getGrade());
        holder.setTextViewText(R.id.tv_class_name,"班级："+item.getClass_name());
        ImageView ivSelector = holder.getView(R.id.iv_selector);

        if (item.getStatus().equals("1")){
            item.setIs_sel(true);
        }else {
            item.setIs_sel(false);
        }

        if (item.is_sel()){
            ivSelector.setSelected(true);
        }else{
            ivSelector.setSelected(false);
        }

        ivSelector.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (item.getStatus().equals("1")){
                    item.setStatus("0");
                }else {
                    item.setStatus("1");
                }
                notifyDataSetChanged();
            }
        });

    }
}
